Ext.define("XTFrame.view.ruiyuan.NewsManager",{
	extend: 'Ext.grid.Panel',
	alias: 'widget.ruiyuanNewsManager',
	region: 'center',
	frame: true,
	autoScroll: true,
	enableKeyNav: true,
	columns: [ Ext.create("Ext.grid.RowNumberer", {width:32}),
				{width: 360, text: '主题', dataIndex: 'subject', sortable: true}, 
				{width: 120, text: '作者', dataIndex: 'autor'}, 
				{width: 120, text: '栏目', dataIndex: 'col_name'}, 
				{width: 160, text: '创建时间', dataIndex: 'create_time'} ],
	tbar: [ {xtype: 'button', text: '添加', action: 'gridAdd', iconCls: 'icon-add'},
			{xtype: 'button', text: '删除', action: 'gridDelete', iconCls: 'icon-delete'},
			{xtype: 'button', text: '修改', action: 'gridEdit', iconCls: 'icon-edit'},
			{xtype: 'button', text: '查询', action: 'gridSearch', iconCls: 'icon-search'} ],
	initComponent: function(){
		var me = this;
		Ext.create('XTFrame.store.ruiyuan.News', {storeId: 'ruiyuan_news',
			listeners:{
				beforeload: function(store, options){
					if(Ext.isEmpty(me.cls) || me.cls == '0'){
						var params = me.up('panelBorder').params;
						if(!Ext.isEmpty(params) && params!=null) me.cls = params.cls;
					}
					var new_params = {
						iFunc: ajaxUtil.FUNC_PAGING,
						strData: Ext.JSON.encode({totalSqlObject: {sqlID: "ruiyuan_news_3", parameters: {subject: me.subject, cls: me.cls}},
							querySqlObject: {sqlID: "ruiyuan_news_4", parameters: {start: options.start, limit: options.limit, subject: me.subject, cls: me.cls}}})
					};
			        Ext.apply(store.proxy.extraParams, new_params);
			    },
			    load: function(store, records, successful){
			    	if(successful){
			    		ajaxUtil.isLogin(store.proxy.reader.jsonData);
			    	}
			    }
			}
		});
		Ext.apply(this,{
			store: Ext.data.StoreManager.lookup('ruiyuan_news'),
			selType: 'checkboxmodel',
			multiSelect: true,
			cls: '0',
			subject: '',
			editWindow: 'XTFrame.view.ruiyuan.NewsEditWindow',
			editWinId: 'ruiyuanNewsEditWindow',
			searchWindow: 'XTFrame.view.ruiyuan.NewsSearchWindow',
			searchWinId: 'ruiyuanNewsSearchWindow',
			addSql: 'ruiyuan_news_6',
			addValues: ['news_id', 'subject', 'content', 'autor', 'subject_img', 'down_url', 'col_id', 'create_time'],
			editSql: 'ruiyuan_news_7',
			editValues: ['news_id', 'subject', 'content', 'autor', 'subject_img', 'down_url', 'col_id'],
			deleteSql: 'ruiyuan_news_5',
			deleteValues: ['news_id'],
			searchValues: ['subject'],
			dockedItems: [{
				xtype: 'pagingtoolbar',
				dock: 'bottom',
				displayInfo: true,
				store: Ext.data.StoreManager.lookup('ruiyuan_news')
			}]
		});
		this.callParent(arguments);
	}
});